<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'name'=>'快快租车分销系统',
    'modules' => [
        'api' => [
            'class' => 'app\module\api\Module'
        ]
    ],
    'components' => [
        'request' => [
            'class' => 'app\components\Request',
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '0qOApIq4G0bP1KUt7G0kHWXj',
            'parsers' => [
                'application/json' => 'yii\web\JsonParser',
            ]
        ],
        'cache' => [
            'class' => 'yii\caching\DbCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'loginUrl' => ['oauth/login'],
            'enableAutoLogin' => true,
            'idParam' => '__user'
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],
        'wechat' => [
            'class' => 'app\extensions\Wechat',
            'appId' => 'wxc17aba9548aa98e6',
            'appKey' => '66840b625f3d4f57891fb932cc8a3f20'
        ],
        'db' => YII_ENV_DEV ? require(__DIR__ . '/debug.php') : require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = 'yii\gii\Module';

    $config['components']['wechat'] = [
        'class' => 'app\extensions\Wechat',
        'appId' => 'wxc17aba9548aa98e6',
        'appKey' => '66840b625f3d4f57891fb932cc8a3f20',
        'token' => '1429867189653'
    ];
}

return $config;
